import requests
from lxml import etree

base_url = "https://www.hello-algo.com/chapter_appendix/terminology/"

response = requests.get(base_url)

if response.status_code == 200:
    # 解析网页源码
    html = response.text
    etree_html = etree.HTML(html)
    words = etree_html.xpath('//div[@class="center-table"]//tr//td[1]//text()')
    for word in words:
        with open("./words.txt", "a+", encoding="utf-8") as f:
            f.write(word + "\n")


